
class SlkAction extends SlkTree {

SlkAction ( SlkToken   scanner )
{              
    super ();

    this.scanner = scanner;
    semantic_stack = new Stack();
    answer = 0;
}

private SlkToken  scanner;
private double    answer;
private Stack     semantic_stack;

public double   get_answer ()          { return  answer; }
public void     state ( int  number ) { }

// -----------------------------------------------------------------------
// grammar action code functions
// -----------------------------------------------------------------------

private
void 
Add ()
{
    double   op;

    answer =  semantic_stack.pop();
    op = semantic_stack.pop();
    if ( op == '+' ) {
        answer = semantic_stack.pop() + answer;
    } else {
        answer = semantic_stack.pop() - answer;
    }
    semantic_stack.push ( answer );
}

private 
void 
Finish ()
{
    answer = semantic_stack.pop();
}

private 
void 
Multiply ()
{
    double   op;

    answer = semantic_stack.pop();
    op = semantic_stack.pop();
    if ( op == '*' ) {
        answer = semantic_stack.pop() * answer;
    } else {
        answer = semantic_stack.pop() / answer;
    }
    semantic_stack.push ( answer );
}

private 
void 
Exponent ()
{
    answer = semantic_stack.pop();
    answer = Math.pow ( semantic_stack.pop(), answer );
    semantic_stack.push ( answer );
}

private 
void 
Negate ()
{
    answer = semantic_stack.pop();
    semantic_stack.push ( -answer );
}

private 
void
Push ()
{
    semantic_stack.push ( scanner.get_attribute() );
}

// #include SlkExecute.txt

};
